package cc.taofoo.Design.Singleton;

import javax.swing.*;
import java.awt.*;

public class Client {
    public static void main(String[] args) {
        JFrame jf = new JFrame("Singleton");    //创建一个JFrame对象
        JDesktopPane jDesktopPane = new JDesktopPane();
        JButton jButton = new JButton("点击创建窗口");

        jButton.addActionListener((e) -> {  // 添加监听时间
            addMySingletonPanel(jDesktopPane);
        });

        jf.setLayout(new BorderLayout());
        jf.setBounds(300, 100, 500, 500);    //设置窗口大小和位置
        jf.add(jDesktopPane, BorderLayout.CENTER);
        jf.add(jButton, BorderLayout.SOUTH);


        jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jf.setVisible(true);
    }
    public static void addMySingletonPanel(JDesktopPane pane){
        pane.removeAll();
        pane.add(MySingletonPanel.getInstance());
    }

}
